<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>DOM编程</title>
	<script>
		function createImage(){
			//1.创建图像元素
			var imageEle = document.createElement('img');
			//2.设置属性
			imageEle.setAttribute('src','images/5b42bdfeN98916c29.jpg');
			//3.获取对象
			var divEle = document.getElementById('div');
			//4.在刚刚获取到的div对象内追加子节点
			divEle.appendChild(imageEle);
			//document.getElementById('div').appendChild('imageEle');			
		}
	</script>
</head>
<body>
	<p>我是段落1</p>
	<div id="div" style="border:2px solid #f00"></div>
	<p>我是段落2</p>
	<input type="button" value="单击我,可以在DIV内创建图像" onclick="createImage()">
</body>
</html>